// pages/orders/detail.js
var app = getApp();
Page({
  data:{
    oid:0,
    orderInfo:[],
    proData:[],
  },
  onLoad: function (options) {
    var that=this;
    that.setData({
      oid:options.oid,
    })
    console.log(that.data.oid)
    console.log(options)
  },
  onShow:function(){
    this.loadProductDetail()
  },
  loadProductDetail:function(){
    var that = this;
    wx.request({
      url: app.d.ceshiUrl + '/Api/GroupOrder/order_details',
      method:'post',
      data: {
        order_id: that.data.oid,
      },
      header: {
        'Content-Type':  'application/x-www-form-urlencoded'
      },
      success: function (res) {
        var status = res.data.status;
        console.log(res)
        if(status==1){
          var pro = res.data.pro;
          var ord = res.data.ord;
          that.setData({
            orderInfo: ord,
            proData:pro
          });
        }else{
          wx.showToast({
            title: res.data.err,
            duration: 2000
          });
        }
      },
      fail: function () {
          // fail
          wx.showToast({
            title: '网络不给力！',
            duration: 2000
          });
      }
    });
  },
  toPay:function(){
    var self = this;
   app.request.wxRequest({
     url:'wx-pay',
     data:{oid:this.oid},
     success:function(res){   

     }
   })
  },
  confirmReceipt:function(){
   var self = this;
   wx.showModal({
     content: '是否确认收货？',
     success: function(res) {
       if (res.confirm) {

       }
     }
   })
  },
  toGroupDetail:function(e){
  var id = e.currentTarget.dataset.id;
  wx.redirectTo({
       url: '../group/detail?gid='+ id
  });
 },
})